package com.lagou.config;

import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.io.ResourceLoader;
import org.springframework.util.Assert;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;

import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashSet;

public class SpringApplication {
    public static void run(Class<?> primarySource, String... args) throws Exception {
        //1、初始化IOC 通过注解的方式初始化Spring的上下文
        AnnotationConfigWebApplicationContext ac = new AnnotationConfigWebApplicationContext();
        //注册spring的配置类（替代传统项目中xml的configuration）
        ac.register(AppConfig.class);
        ac.refresh();
        //2、获取&启动tomcat
        WebServerFactory webServerFactory = ac.getBean(WebServerFactory.class);
        webServerFactory.createServer();
        //3、rvl将DispatcherSeet添加到tomcat上下文ServletContext中去
        //实例化MySpringServletContainerInitializer，并回调类中的onStartup方法。
    }

}
